package cate.common.table.task.sheet;

import cate.common.table.ESheet;
import cate.common.table.task.row.HistoryRow;
import easy.java.dev.note.NoteClass;

import java.util.ArrayList;
import java.util.List;


@NoteClass("永久历史")
public class HistorySheet extends ESheet<HistoryRow> {

    @Override
    public String getSheetName() {
        return "永久历史";
    }

    @Override
    protected HistoryRow buildRow() {
        return new HistoryRow();
    }

    public HistoryRow find(int event, int param) {
        for (HistoryRow row : list) {
            if (row.event == event && row.param == param) {
                return row;
            }
        }
        return null;
    }

    public List<HistoryRow> findByGEParam(int event, int param) {
        List<HistoryRow> tmpList = new ArrayList<>();
        for (HistoryRow row : list) {
            if (row.event == event && row.param >= param) {
                tmpList.add(row);
            }
        }
        return tmpList;
    }

    public List<HistoryRow> findByLEParam(int event, int param) {
        List<HistoryRow> tmpList = new ArrayList<>();
        for (HistoryRow row : list) {
            if (row.event == event && row.param <= param) {
                tmpList.add(row);
            }
        }
        return tmpList;
    }
}
